<template>
	<view class="bg">
		<view class="bgg-color"></view>
		<!-- 		<image class="bgc-img" src='../../static/bg1.png'></image> -->
		<view class="gameLayout">
			<view class="title">
				比赛赛事信息
			</view>
			<view class="content">
				<view class="games">
					<!--比赛内容（可点击） -->
					<view class="title">
						{{}}
					</view>
					<view class="newsContainer" v-for="item in news" key="index">
						<view class="newsLeft">
							<image :src="item.logPath" mode="aspectFill"></image>
							<view class="stateTag">
								<uni-tag :inverted="true" :text="item.state" type="primary" />
							</view>
						</view>
						<view class="newsRight">
							<view class="text" @click="onGameClick(item)">
								<!-- <navigator url="gameInfo/gameInfo" hover-class="navigator-hover"> -->
								<text font-size=50rpx>{{item.name}}</text>
								<!-- </navigator> -->
							</view>
							<view class="time">
								<text class="timesplice">{{item.selectedDate}}</text>
								<view class="state"><text class="state">{{item.state}}
										{{item.personNum}}/{{2*item.competitionSystem}}</text></view>
							</view>

						</view>
					</view>
					<navigator url="/pages/sponser/sponser">
						<view class="button">
							<text class="textGame" style="font-size:30px;">+</text>
						</view>
					</navigator>
				</view>

				<view class="float">
					<view class="item" @click="onTop">
						<uni-icons type="up" size="30"></uni-icons>
					</view>
					<!-- 			<view class="item" @click="onRefresh">
				<uni-icons type="loop" size="30"></uni-icons>
			</view> -->
				</view>

			</view>
		</view>

	</view>
</template>

<script setup>
	import {
		onMounted,
		ref
	} from 'vue';
	import {
		onReachBottom,
		onPullDownRefresh
	} from "@dcloudio/uni-app";
	import {
		baseUrl
	} from '../../tool/tool';
	import {
		onShow
	} from "@dcloudio/uni-app"

	function onTop() {
		uni.pageScrollTo({
			scrollTop: 0,
			duration: 250
		})
	};

	function onRefresh() {
		uni.startPullDownRefresh();
	}

	let news = ref([])
	let mystate = ref()
	onShow(() => {
		uni.request({
			url: baseUrl + "/SeriesGame/getAllSeriesGame",
			method: "POST",
			success(res) {
				news.value = res.data;

			}
		})

		console.log("123 " + news.value)
	});

	function onGameClick(item) {
		uni.navigateTo({
			url: "/pages/gameInfo/gameInfo?news=" + encodeURIComponent(JSON.stringify(item))
		});
	}

	onPullDownRefresh(() => {
		// console.log(123);
		news.value = []; // 立即清空news数组

		// 一秒后更新news数据
		setTimeout(() => {
			Refresh();
			// 数据更新后再等待一秒，然后停止下拉刷新
			setTimeout(uni.stopPullDownRefresh, 100);
		}, 1000); // 等待1秒后执行
	});


	const isActive = ref(false);
	const selectedIndex = ref(-1); // 用于存储选中项目的索引



	const toggleActive = () => {
		isActive.value = true;

		setTimeout(() => {
			isActive.value = false;
		}, 300);
	};

	const selectItem = (index) => {
		selectedIndex.value = index;
	};
</script>

<style lang="scss" scoped>
	html,
	body {
		height: 100%;
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		// background: linear-gradient(to left, #606c88, #3f4c6b);
		font-family: 'Oswald', sans-serif;
	}

	.bgg-color {
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		background: linear-gradient(#BBE5FD 0%, #D2DAFD 49%, #fff 100%);
		z-index: -1;
	}



	.button {
		display: flex; /* 启用Flexbox布局 */  
		  justify-content: center; /* 水平居中 */  
		  align-items: center; /* 垂直居中 */  
		width: 690rpx;
		height: 220rpx;
		margin-top: 10px;
		border-radius: 10px;
		border: 2px #fff dashed;
	}

	/* .gameLayout {
  display: flex;
  justify-content: center;
  padding: 16rpx;
} */
	// .bgc-img {
	// 	filter: blur(4px);
	// 	opacity: 0.8;
	// 	position: fixed;
	// 	width: 100%;
	// 	height: 100%;
	// 	top: 0;
	// 	left: 0;
	// 	z-index: -1;
	// }

	.gameLayout {
		.title {
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 30rpx;
			font-weight: bold;
			margin-top: 10rpx;
			margin-left: 25rpx;
		}

		.content {
			width: 600rpx;
			margin-left: 75rpx;
			margin-right: 75rpx;
			margin-top: 30rpx;

			scroll-view {
				white-space: nowrap;

				.subTitle {
					width: 150rpx;
					height: 40rpx;
					display: inline-block;
					line-height: 30rpx;
					text-align: center;
					cursor: pointer;
					user-select: none;
					position: relative;

				}

				.subTitle.selected::after {
					display: flex;
					align-items: center;
					justify-content: center;
					content: '';
					/* 				display: block; */
					position: absolute;
					bottom: -5rpx;
					left: 20%;
					width: 60%;
					height: 8rpx;
					background-color: #1296db;
					margin-top: 5rpx;
					border-radius: 30%;
				}
			}
		}

	}

	.games {
		width: 690rpx;
		margin-left: -35rpx;
		margin-right: 30rpx;
		height: 980rpx;

		.newsContainer {
			width: 100%;
			height: 250rpx;
			display: flex;
			justify-content: space-between;
			margin-top: 20rpx;
			border: 2px solid rgba(0, 0, 0, 0.2);
			/* 设置淡淡的边框 */
			border-radius: 20rpx;
			/* 添加圆角 */
			box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.1);

			/* 根据需要调整 newsLeft 和 newsRight 之间的间距 */
			.newsLeft {
				margin-top: 15rpx;
				margin-bottom: 15rpx;
				width: 220rpx;
				height: 220rpx;
				// background: #1296db;
				margin-right: 30rpx;
				position: relative;

				image {
					width: 100%;
					height: 100%;
					border-radius: 10rpx;
				}

				.stateTag {
					position: absolute;
					top: 0;
					/* 根据需要调整 */
					left: 0;
					/* 根据需要调整 */
					right: 1;
					/* 横向铺满 */
					bottom: 0;
					/* 纵向铺满，或根据需要调整位置 */

				}
			}

			.newsRight {
				flex: 1;
				// background: #666;
			}

			.text {
				margin-top: 20rpx;
				height: 150rpx;
			}

			.time {
				font-size: 25rpx;
				color: #666;
				//display: flex;
				justify-content: space-between;
				align-items: flex-end;

				.timesplice {
					width: 70%;
				}
			}

		}
	}

	.float {
		position: fixed;
		right: 30rpx;
		bottom: 120rpx;

		.item {
			width: 90rpx;
			height: 90rpx;
			background: rgba(255, 255, 255, 0.93);
			border-radius: 50%;
			margin-bottom: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 1px solid #eee;
		}
	}
</style>